package com.phiture.erp.common.enums;


import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

@Getter
@AllArgsConstructor
public enum ErpProductionTaskStatusEnum {
    TO_BE_PRODUCED(1, "待生产"),
    IN_PRODUCTION(2, "生产中"),
    COMPLETED(3, "已完成"),
    CANCELED(4, "已取消");
    private final Integer code;
    private final String name;

    public static Map<Integer, String> getMap() {
        return Arrays.stream(values()).collect(Collectors.toMap(ErpProductionTaskStatusEnum::getCode, ErpProductionTaskStatusEnum::getName));
    }

    // 提供一个根据code 获取状态名称的方法
    public static String getStatusName(Integer code) {
        return Arrays.stream(values())
                .filter(status -> status.getCode().equals(code))
                .map(ErpProductionTaskStatusEnum::getName)
                .findFirst()
                .orElse(null);
    }
}
